import {defineMock} from '@alova/mock';
import {createMock} from '@/mock/utils';
import {join, sampleSize} from 'lodash-es';
import {ResultEnum} from '@/enums/httpEnum';
import {getEnvValue} from '@/utils/env';
const createRandomToken = (len = 36 * 6) => {
    const token = join(sampleSize('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-', len), '');
    return `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.${token}`;
};
const createUserInfo = () => {
    const token = createRandomToken();
    return {
        token:token,
        phone:'13511977628',
        headSculpture:getEnvValue<string>('VITE_COMMON_IMGUR_PREFIX')+'default_tx.png',
        nickName:'昵称昵称',
        sex:1,
        birthday:'2023-12-12',
        isVoluntaryIntention:false,
        isVoluntaryIntention2:false
    }
}
export const authMocks = defineMock({
    // 登录
    '[POST]/api/v1/login': (params) => {
        const {code, encryptedData, iv} = params.data;
        if (code != '' || encryptedData != '' || iv != '') {
            return createMock({data: createUserInfo()});
        }
        return createMock({data: [], code: ResultEnum.FAIL, message: '参数错误'});
    },
});
